home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / compguid / spacespr / noticwin.sx
Encoding:
Text File  |  1996-05-21  |  1.4 KB  |  54 lines  |  [TEXT/ttxt]

  1. -- <<<-
  2.  
  3. -- noticwin.sx
  4. -- by Doug "obsolete license plate" Kramer
  5.  
  6. -- "Spaces and Presenters"
  7. -- ScriptX Components Guide
  8.  
  9. module SpacesTest1 uses ScriptX end
  10. in module SpacesTest1
  11.  
  12.  
  13.  
  14. class ClosableNoticeWindow (Window)
  15. end
  16.  
  17. method init self {class ClosableNoticeWindow} #rest args ->
  18.     apply nextMethod self type:@notice args      -- calls init on superclasses
  19.  
  20. method afterInit self {class ClosableNoticeWindow} #rest args -> (
  21.     apply nextMethod self args      -- calls init on superclasses
  22.  
  23.     -- create an actuator controller for any pushbuttons in the window
  24.     new ActuatorController space:self wholespace:true
  25.  
  26.     -- create the pushbutton
  27.     local closeButton := new Pushbutton 
  28.     closeButton.x := 75
  29.     closeButton.y := 90
  30.     closeButton.stroke := blackBrush
  31.        
  32.     -- define the released presenter
  33.     local buttonText := new TextPresenter \
  34.         boundary:(new Rect x2:50 y2:20) target:"Close"
  35.     setDefaultAttr buttonText @alignment @center
  36.     closeButton.releasedPresenter := buttonText 
  37.  
  38.     -- define the pressed presenter
  39.     closeButton.pressedPresenter := new TwoDShape \
  40.         target:(new Rect x2:50 y2:20) fill:blackBrush 
  41.  
  42.     -- define the window to hide when mouse button is released
  43.     closeButton.activateAction := (undefined button ->
  44.         hide button.presentedBy)
  45.  
  46.     -- append the button to the window and show the window
  47.     append self closeButton
  48.     show self
  49. )
  50.  
  51. new ClosableNoticeWindow centered:true boundary:(new Rect x2:200 y2:200)
  52.  
  53. -- >>>
  54.